package com.dnxh.constant;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * The type Custom result.
 *
 * @Author 枳湫
 * @Time 2022 /4/6 11:06
 * @Describe Basic_jar
 */
@Data
@Accessors(chain = true)
public class CustomResult {
	
	private int code;
	private String message;
	private Object data;
	
	/**
	 * Instantiates a new Custom result.
	 *
	 * @param code    the code
	 * @param message the message
	 * @param data    the data
	 */
	public CustomResult(int code,String message,Object data){
		this.code = code;
		this.message = message;
		this.data = data;
	}
	
	/**
	 * Success custom result.
	 *
	 * @param data the data
	 * @return the custom result
	 */
	public static CustomResult success(Object data){
		return new CustomResult (200,CommonConstant.SUCCESS,data);
	}
	
	/**
	 * Success custom result.
	 *
	 * @return the custom result
	 */
	public static CustomResult success(){
		return new CustomResult (200,CommonConstant.SUCCESS,CommonConstant.SUCCESS);
	}
	
	/**
	 * Fail custom result.
	 *
	 * @param message the message
	 * @return the custom result
	 */
	public static CustomResult fail(String message){
		return new CustomResult (2000,CommonConstant.FAILURE,message);
	}
	
	/**
	 * Common custom result.
	 *
	 * @param code    the code
	 * @param message the message
	 * @param data    the data
	 * @return the custom result
	 */
	public static CustomResult common(int code,String message,Object data){
		return new CustomResult (code,message,data);
	}
}
